package com.fs.service.bo.purchase;

import com.fs.entity.PurchaseRecord;
import com.fs.entity.PurchaseState;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@NoArgsConstructor
public class BoPurchase {
    private int id;
    private Float amount;
    private LocalDateTime createTime;
    private LocalDateTime beginTime;
    private LocalDateTime endTime;
    private Status state;
    private String tradeNo;
    private boolean lock;

    public BoPurchase(PurchaseRecord purchase) {
        this.id = purchase.getId();
        this.amount = purchase.getAmount();
        this.createTime = purchase.getCreateDate();
        this.beginTime = purchase.getBeginTime();
        this.endTime = purchase.getEndTime();
        this.state = Status.transfer(purchase.getState(), purchase.getBeginTime(), purchase.getEndTime());
        tradeNo = purchase.getTradeNo();
        lock = purchase.getPayingLock();
    }
}
